<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/headeradmin.php");
?>

<section>
<hgroup>
<h1>Functionele bewegingsmogelijkheid activeren</h1>
</hgroup>
<?php 
    if (isset($_POST["bevestiging"]))
    {
        $query="SELECT * FROM movementrestriction WHERE Id='" .$_POST["id"]."'";
        $result = mysql_query($query) or die ("FOUT1: " . mysql_error());

        while ($row = mysql_fetch_array($result)){
            $name = $row['MRKey'];
        }
        
        $query2 = "UPDATE movementrestriction SET Activated='T' WHERE Id = '".$_POST["id"]."'";
        $result2 = mysql_query($query2) or die ("FOUT2: " . mysql_error());
        if ($result2)
        {
            echo ("<p>Functionele bewegingsmogelijkheid " .$name . " is geactiveerd<br>\n");
            echo ("<a href=\"funcbewoverzicht.php?start=".$_POST['start']."\">Terug naar het overzicht van functionele bewegingsmogelijkheden.</a></p>");
        }
    }
    else
    {
        $query="SELECT * FROM movementrestriction WHERE Id='" .$_GET["id"]."'";
        $result = mysql_query($query) or die ("FOUT1: " . mysql_error());

        while ($row = mysql_fetch_array($result)){
            echo "<p>Functionele bewegingsmogelijkheid = " . $row['MRKey'] . "<br>\n";
        }
?>
<form action="<?php echo($_SERVER["PHP_SELF"]);?>" method="post">
    <p>
        <input type="hidden" name="bevestiging" value="1" />
        <input type="hidden" name="id" value="<?php echo($_GET["id"]);?>" />
        <input type="hidden" name="start" value="<?php if (isset($_GET['start'])){ echo $_GET['start']; } else { echo 0; }  ?>" />
        <input type="submit" value="Ja, activeren" />
        <input type="button" value="Nee, terug" onclick="javascript:history.back();" />
    </p>
</form>
<?php
    }
?>
</section>

<?php
    include($_SERVER['DOCUMENT_ROOT']."/ObstacleWebApp/view/footer.php");
?>